package com.logo.egitim.crm.dao;

import java.io.Serializable;
import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
import javax.persistence.PersistenceContext;

public abstract class GenericDao<E> implements Serializable {

	@PersistenceContext
	EntityManager entityManager;

	public void kaydet(E nesne) {
		entityManager.persist(nesne);
	}

	public void sil(E nesne) {
		nesne = entityManager.merge(nesne);
		entityManager.remove(nesne);
	}

	public void duzenle(E nesne) {
		entityManager.merge(nesne);
	}

	public List<E> liste() {
		return entityManager.createQuery(getSorgu()).getResultList();
	}

	public abstract String getSorgu();
	
	public void yenile(E nesne){
		entityManager.refresh(nesne);
	}
	
}













